package com.loveprogrammer.eternity.model.product.eggs;

import com.loveprogrammer.eternity.enums.MonsterQualityEnum;
import com.loveprogrammer.eternity.enums.QualityEnum;
import com.loveprogrammer.eternity.factory.MonsterFactory;
import com.loveprogrammer.eternity.factory.template.MonsterTemplate;
import com.loveprogrammer.eternity.model.Monster;
import com.loveprogrammer.eternity.model.game.HeroWrapper;
import com.loveprogrammer.eternity.model.product.Coin;
import com.loveprogrammer.eternity.model.product.Goods;

import java.io.Serializable;
import java.util.Random;

/**
 * @version 1.0.0
 * @description:
 * @author: eric
 * @date: 2022-08-30 16:52
 **/
public class Egg extends Goods implements Comparable<Egg>{

    private MonsterTemplate monsterTemplate;

    public Egg(String name, String type, String desc, QualityEnum quality,
               MonsterTemplate monsterTemplate) {
        super(name, type, desc, quality,monsterTemplate.getId());
        this.monsterTemplate = monsterTemplate;
    }

    @Override
    public Coin sale() {
        Coin coin = new Coin();
        coin.setGoldCoin(200 * monsterTemplate.getQuality() * monsterTemplate.getQuality());
        return coin;
    }

    @Override
    public Coin price() {
        // TODO
        return sale();
    }

    // 物品打印信息的重写
    public String prettyPrint() {
        return  string+"****物品信息****\n"+
                string+"名称："+ this.getName() +"\n"+
                string+"天赋："+ this.quality.getDesc() +"\n"+
                string+"血统："+ MonsterQualityEnum.getByLevel(this.monsterTemplate.getQuality()).getDesc() +"\n"+
                string+"说明："+ "帝王>君主>统领>战将>奴仆 史诗>传奇>卓越>优质>进阶>普通" +"\n"+
                string+""+"***************";
    }

    public Monster hatch() {
        // 孵化出来的是什么品质的野怪
        return MonsterFactory.createMonster(monsterTemplate,1,
                QualityEnum.getById(new Random().nextInt(6)),true);
    }

    public MonsterTemplate getMonsterTemplate() {
        return monsterTemplate;
    }

    public void setMonsterTemplate(MonsterTemplate monsterTemplate) {
        this.monsterTemplate = monsterTemplate;
    }

    @Override
    public int compareTo(Egg egg) {
        return this.monsterTemplate.getQuality() - egg.monsterTemplate.getQuality();
    }
}
